// zh_gjw/pages/cgoods/cgoods.js
Page({

  /**
   * 页面的初始数据
   */
	data: {
		pageo: 1,
		paget: 1,
		pageth: 1,
		pagefi: 1,
		pagef: 1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
	onLoad: function (options) {
		var that = this
		getApp().location_attachurl(this)
		getApp().location_url(this)
		that.setData({
			phone:options.admin
		})
		getApp().util.request({
			url: 'entry/wxapp/primoney',
			success: function (res) {
				
				that.setData({
					priupfee: res.data.res.upfee,
					pritopfee: res.data.res.topfee,
				})
			}
		})
		getApp().util.request({
			url: 'entry/wxapp/shotmoney',
			success: function (res) {
				
				that.setData({
					shotupfee: res.data.res.upfee,
					shottopfee: res.data.res.topfee,
				})
			}
		})
		getApp().util.request({
			url: 'entry/wxapp/dbmoney',
			success: function (res) {
				that.setData({
					dbupfee: res.data.res.upfee,
					dbtopfee: res.data.res.topfee,
				})
			}
		})
		getApp().util.request({
			url: 'entry/wxapp/marketmoney',
			success: function (res) {
				
				that.setData({
					marketupfee: res.data.res.upfee,
					markettopfee: res.data.res.topfee,
				})
			}
		})
		getApp().util.request({
			url: 'entry/wxapp/storemoney',
			success: function (res) {
				that.setData({
					storeupfee: res.data.res.upfee,
					storetopfee: res.data.res.topfee,
				})
			}
		})
		getApp().util.request({
			url: 'entry/wxapp/Repucostdbut',
			data: { openid: wx.getStorageSync('openid') },
			success: function (res) {
				if (res.data.code == 200) {
					that.setData({
						dbrestups: res.data.restups,
						dbresttops: res.data.resttops
					})
				}
			}
		})
		getApp().util.request({
			url: 'entry/wxapp/Repucostshotut',
			data: { openid: wx.getStorageSync('openid') },
			success: function (res) {
				if (res.data.code == 200) {
					that.setData({
						shotrestups: res.data.restups,
						shotresttops: res.data.resttops
					})
				}
			}
		})
		getApp().util.request({
			url: 'entry/wxapp/Repucostmarketut',
			data: { openid: wx.getStorageSync('openid') },
			success: function (res) {
				if (res.data.code == 200) {
					that.setData({
						marketrestups: res.data.restups,
						marketresttops: res.data.resttops
					})
				}
			}
		})
		getApp().util.request({
			url: 'entry/wxapp/Repucoststoresut',
			data: { openid: wx.getStorageSync('openid') },
			success: function (res) {
				if (res.data.code == 200) {
					that.setData({
						storesrestups: res.data.restups,
						storesresttops: res.data.resttops
					})
				}
			}
		})
		getApp().util.request({
			url: 'entry/wxapp/Repucostforyouut',
			data: { openid: wx.getStorageSync('openid') },
			success: function (res) {
				if (res.data.code == 200) {
					that.setData({
						foryourestups: res.data.restups,
						foryouresttops: res.data.resttops
					})
				}
			}
		})
		if (options.dbm == 'dbm') {
			getApp().util.request({
				'url': 'entry/wxapp/dbm',
				'cachetime': '0',
				data: { phone: options.admin, page: that.data.pageo },
				success: function (res) {
					that.setData({
						dbmlist: res.data.res,

					})
				}
			});
			that.setData({
				dbm: 'active',
				
			})
		}
		if (options.shotm == 'shotm') {
			getApp().util.request({
				'url': 'entry/wxapp/shotm',
				'cachetime': '0',
				data: { phone: options.admin, page: that.data.paget },
				success: function (res) {
					that.setData({
						shotmlist: res.data.res,

					})
				}
			});
			that.setData({
				shotm: 'active'
			})
		}
		if (options.marketm == 'marketm') {
			getApp().util.request({
				'url': 'entry/wxapp/marketm',
				'cachetime': '0',
				data: { phone: options.admin, page: that.data.pageth },
				success: function (res) {
					that.setData({
						marketmlist: res.data.res,

					})
				}
			});
			that.setData({
				marketm: 'active'
			})
		}
		if (options.storem == 'storem') {
			getApp().util.request({
				'url': 'entry/wxapp/storem',
				'cachetime': '0',
				data: { phone: options.admin, page: that.data.pagefi },
				success: function (res) {
					that.setData({
						storemlist: res.data.res,

					})
				}
			});
			that.setData({
				storem: 'active'
			})
		}
		if (options.prim == 'prim') {
			getApp().util.request({
				'url': 'entry/wxapp/prim',
				'cachetime': '0',
				data: { phone: options.admin, page: that.data.pagef },
				success: function (res) {
					that.setData({
						primlist: res.data.res,

					})
				}
			});
			that.setData({
				prim: 'active'
			})
		} 
  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
		var that = this
		if (that.data.dbm == 'active') {
			that.data.pageo = that.data.pageo + 1
			getApp().util.request({
				'url': 'entry/wxapp/dbm',
				'cachetime': '0',
				data: { phone: that.data.phone, page: that.data.pageo },
				success: function (res) {
					if (res.data.code == 500) {
						wx.showToast({
							title: '没有新的数据了！',
							icon: 'none'
						})
					}
					if(res.data.code==200){
						for (var j = 0; j < res.data.res.length; j++) {
							that.data.dbmlist.push(res.data.res[j])
						}
						that.setData({
							dbmlist: that.data.dbmlist
						})
					}
				}
			});
		}
		if (that.data.shotm == 'active') {
			that.data.paget = that.data.paget + 1
			getApp().util.request({
				'url': 'entry/wxapp/shotm',
				'cachetime': '0',
				data: { phone: that.data.phone, page: that.data.paget },
				success: function (res) {
					if (res.data.code == 500) {
						wx.showToast({
							title: '没有新的数据了！',
							icon: 'none'
						})
					}
					if (res.data.code == 200) {
						for (var j = 0; j < res.data.res.length; j++) {
							that.data.shotmlist.push(res.data.res[j])
						}
						that.setData({
							shotmlist: that.data.shotmlist
						})
					}
				}
			});
		}
		if (that.data.marketm == 'active') {
			that.data.pageth = that.data.pageth + 1
			getApp().util.request({
				'url': 'entry/wxapp/marketm',
				'cachetime': '0',
				data: { phone: that.data.phone, page: that.data.pageth },
				success: function (res) {
					if (res.data.code == 500) {
						wx.showToast({
							title: '没有新的数据了！',
							icon: 'none'
						})
					}
					if (res.data.code == 200) {
						for (var j = 0; j < res.data.res.length; j++) {
							that.data.marketmlist.push(res.data.res[j])
						}
						that.setData({
							marketmlist: that.data.marketmlist
						})
					}
				}
			});
		}
		if (that.data.storem == 'active') {
			that.data.pagefi = that.data.pagefi + 1
			getApp().util.request({
				'url': 'entry/wxapp/storem',
				'cachetime': '0',
				data: { phone: that.data.phone, page: that.data.pagefi },
				success: function (res) {
					if (res.data.code == 500) {
						wx.showToast({
							title: '没有新的数据了！',
							icon: 'none'
						})
					}
					if (res.data.code == 200) {
						for (var j = 0; j < res.data.res.length; j++) {
							that.data.storemlist.push(res.data.res[j])
						}
						that.setData({
							storemlist: that.data.storemlist
						})
					}
				}
			});
		}
		if (that.data.prim == 'active') {
			that.data.pagef = that.data.pagef + 1
			getApp().util.request({
				'url': 'entry/wxapp/prim',
				'cachetime': '0',
				data: { phone: that.data.phone, page: that.data.pagef },
				success: function (res) {
					if (res.data.code == 500) {
						wx.showToast({
							title: '没有新的数据了！',
							icon: 'none'
						})
					}
					if (res.data.code == 200) {
						for (var j = 0; j < res.data.res.length; j++) {
							that.data.primlist.push(res.data.res[j])
						}
						that.setData({
							primlist: that.data.primlist
						})
					}
				}
			});
		}
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
	},
	// 获取滚动条当前位置
	onPageScroll: function (e) {
	},
	dbm: function () {
		var that = this
		if(wx.pageScrollTo) {
				wx.pageScrollTo({
					scrollTop: 0
				})
		} else {
			wx.showModal({
				title: '提示',
				content: '当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试。'
			})
		}
		that.data.pageo=1
		getApp().util.request({
			'url': 'entry/wxapp/dbm',
			'cachetime': '0',
			data: { phone: that.data.phone, page: that.data.pageo },
			success: function (res) {
				that.setData({
					dbmlist: res.data.res,
					shotmlist: '',
					marketmlist: '',
					storemlist: '',
					primlist: '',

				})
			}
		});
		that.setData({
			dbm: 'active',
			shotm: '',
			marketm: '',
			storem: '',
			prim: '',
		})
	},
	shotm: function () {
		var that = this
		if (wx.pageScrollTo) {
			wx.pageScrollTo({
				scrollTop: 0
			})
		} else {
			wx.showModal({
				title: '提示',
				content: '当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试。'
			})
		}
		that.data.paget = 1
		getApp().util.request({
			'url': 'entry/wxapp/shotm',
			'cachetime': '0',
			data: { phone: that.data.phone, page: that.data.paget },
			success: function (res) {
				that.setData({
					dbmlist: '',
					shotmlist: res.data.res,
					marketmlist: '',
					storemlist: '',
					primlist: '',

				})
			}
		});
		that.setData({
			dbm: '',
			shotm: 'active',
			marketm: '',
			storem: '',
			prim: '',
		})
	},
	marketm: function () {
		var that = this
		if (wx.pageScrollTo) {
			wx.pageScrollTo({
				scrollTop: 0
			})
		} else {
			wx.showModal({
				title: '提示',
				content: '当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试。'
			})
		}
		that.data.pageth = 1
		getApp().util.request({
			'url': 'entry/wxapp/marketm',
			'cachetime': '0',
			data: { phone: that.data.phone, page: that.data.pageth },
			success: function (res) {
				that.setData({
					dbmlist: '',
					shotmlist: '',
					marketmlist: res.data.res,
					storemlist: '',
					primlist: '',

				})
			}
		});
		that.setData({
			dbm: '',
			shotm: '',
			marketm: 'active',
			storem: '',
			prim: '',
		})
	},
	storem: function () {
		var that = this
		if (wx.pageScrollTo) {
			wx.pageScrollTo({
				scrollTop: 0
			})
		} else {
			wx.showModal({
				title: '提示',
				content: '当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试。'
			})
		}
		that.data.pagefi = 1
		getApp().util.request({
			'url': 'entry/wxapp/storem',
			'cachetime': '0',
			data: { phone: that.data.phone, page: that.data.pagefi },
			success: function (res) {
				that.setData({
					dbmlist: '',
					shotmlist: '',
					marketmlist: '',
					storemlist: res.data.res,
					primlist: '',

				})
			}
		});
		that.setData({
			dbm: '',
			shotm: '',
			marketm: '',
			storem: 'active',
			prim: '',
		})
	},
	prim: function () {
		var that = this
		if (wx.pageScrollTo) {
			wx.pageScrollTo({
				scrollTop: 0
			})
		} else {
			wx.showModal({
				title: '提示',
				content: '当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试。'
			})
		}
		that.data.pagef = 1
		getApp().util.request({
			'url': 'entry/wxapp/prim',
			'cachetime': '0',
			data: { phone: that.data.phone, page: that.data.pagef },
			success: function (res) {
				that.setData({
					dbmlist: '',
					shotmlist: '',
					marketmlist: '', 
					storemlist:'',
					primlist: res.data.res,

				})
			}
		});
		that.setData({
			dbm: '',
			shotm: '',
			marketm: '',
			storem: '',
			prim: 'active',
		})
	},
	detele:function(e){
		var that=this
		getApp().util.request({
			'url': 'entry/wxapp/mdetele',
			'cachetime': '0',
			data: { id: e.currentTarget.dataset.id, mtype: e.currentTarget.dataset.type },
			success: function (res) {
				if (e.currentTarget.dataset.type==0){
					// for (var i = 0; i < that.data.dbmlist.length; i++) {
						that.data.dbmlist.splice(e.currentTarget.dataset.index,1)
					// }
					that.setData({
						dbmlist: that.data.dbmlist
					})
				}
				if (e.currentTarget.dataset.type == 1) {
					// for (var i = 0; i < that.data.shotmlist.length; i++) {
						that.data.shotmlist.splice(e.currentTarget.dataset.index, 1)
					// }
					that.setData({
						shotmlist: that.data.shotmlist
					})
				}
				if (e.currentTarget.dataset.type == 2) {
					// for (var i = 0; i < that.data.marketmlist.length; i++) {
						that.data.marketmlist.splice(e.currentTarget.dataset.index, 1)
					// }

					that.setData({
						marketmlist: that.data.marketmlist
					})
				}
				if (e.currentTarget.dataset.type == 3) {
					// for (var i = 0; i < that.data.primlist.length; i++) {
						that.data.storemlist.splice(e.currentTarget.dataset.index, 1)
					// }
					that.setData({
						storemlist: that.data.storemlist
					})
				}
				if (e.currentTarget.dataset.type == 4) {
					// for (var i = 0; i < that.data.primlist.length; i++) {
					that.data.primlist.splice(e.currentTarget.dataset.index, 1)
					// }
					that.setData({
						primlist: that.data.primlist
					})
				}
			}
		});
	},
	dbupfee: function (e) {
		var that = this
		var res_id = e.currentTarget.dataset.id
		var openid = wx.getStorageSync('openid')
		wx.showModal({
			title: '提示',
			content: '是否确认推荐本条抖宝？',
			success: function (res) {
				if (res.confirm) {
					if (that.data.dbupfee > 0) {
						if(that.data.dbrestups>0){
							getApp().util.request({
								url: 'entry/wxapp/dbupsuccess',
								data: {
									id: res_id, openid: openid, tuijian: 1
								},
								success: function (res) {
									if (res.data.code == 200) {
										that.data.dbmlist[e.currentTarget.dataset.index].upfee = 1
										that.setData({
											dbmlist: that.data.dbmlist
										})
										wx.showToast({
											icon: "none",
											title: '推荐成功',
										})
									} else {
										wx.showToast({
											icon: "none",
											title: '推荐失败',
										})
									}
								}
							})
						} else {
							getApp().util.request({
								url: 'entry/wxapp/dbuppay',
								data: {
									openid: openid,
								},
								success: function (res) {
									wx.requestPayment({
										'timeStamp': res.data.timeStamp,
										'nonceStr': res.data.nonceStr,
										'package': res.data.package,
										'signType': 'MD5',
										'paySign': res.data.paySign,
										'success': function (res) {
											getApp().util.request({
												url: 'entry/wxapp/dbupsuccess',
												data: {
													id: res_id
												},
												success: function (rest) {
													if (rest.data.code == 200) {
														that.data.dbmlist[e.currentTarget.dataset.index].upfee = 1
														that.setData({
															dbmlist: that.data.dbmlist
														})
														wx.showToast({
															icon: "none",
															title: '推荐成功',
														})
													} else {
														wx.showToast({
															icon: "none",
															title: '推荐失败',
														})
													}
												}
											})

										},
										'fail': function (res) {
											wx.showToast({
												title: '支付失败',
												icon: "loading",
											})
										}
									})
								}
							})
						}
					}
					else {
						getApp().util.request({
							url: 'entry/wxapp/dbupsuccess',
							data: {
								id: res_id
							},
							success: function (res) {
								
								if (res.data.code == 200) {
									that.data.dbmlist[e.currentTarget.dataset.index].upfee = 1
									that.setData({
										dbmlist:that.data.dbmlist
									})
									wx.showToast({
										icon: "none",
										title: '推荐成功',
									})
								} else {
									wx.showToast({
										icon: "none",
										title: '推荐失败',
									})
								}
							}
						})
					}
				} else if (res.cancel) {
				}
			}
		})
	},

	dbtopfee: function (e) {
		var that = this
		var res_id = e.currentTarget.dataset.id
		var openid = wx.getStorageSync('openid')
		wx.showModal({
			title: '提示',
			content: '是否确认置顶本条抖宝？',
			success: function (res) {
				if (res.confirm) {
					if (that.data.dbtopfee > 0) {
						if (that.data.dbresttops > 0) {
							getApp().util.request({
								url: 'entry/wxapp/dbtopsuccess',
								data: {
									id: res_id,openid:openid,tops:1
								},
								success: function (res) {
									if (res.data.code == 200) {
										wx.showToast({
											icon: "none",
											title: '置顶成功',
										})
									} else {
										wx.showToast({
											icon: "none",
											title: '置顶失败',
										})
									}
								}
							})
						} else {
							getApp().util.request({
								url: 'entry/wxapp/dbtoppay',
								data: {
									openid: openid,
								},
								success: function (res) {
									wx.requestPayment({
										'timeStamp': res.data.timeStamp,
										'nonceStr': res.data.nonceStr,
										'package': res.data.package,
										'signType': 'MD5',
										'paySign': res.data.paySign,
										'success': function (res) {
											getApp().util.request({
												url: 'entry/wxapp/dbtopsuccess',
												data: {
													id: res_id
												},
												success: function (rest) {
													if (rest.data.code == 200) {
														wx.showToast({
															icon: "none",
															title: '置顶成功',
														})
													} else {
														wx.showToast({
															icon: "none",
															title: '置顶失败',
														})
													}
												}
											})

										},
										'fail': function (res) {
											wx.showToast({
												title: '支付失败',
												icon: "loading",
											})
										}
									})
								}
							})
						}
					}
					else {
						getApp().util.request({
							url: 'entry/wxapp/dbtopsuccess',
							data: {
								id: res_id
							},
							success: function (res) {
								if (res.data.code == 200) {
									wx.showToast({
										icon: "none",
										title: '置顶成功',
									})
								} else {
									wx.showToast({
										icon: "none",
										title: '置顶失败',
									})
								}
							}
						})
					}
				} else if (res.cancel) {
					
				}
			}
		})
	},
	shotupfee: function (e) {
		var that = this
		var res_id = e.currentTarget.dataset.id
		var openid = wx.getStorageSync('openid')
		wx.showModal({
			title: '提示',
			content: '是否确认推荐本条微拍？',
			success: function (res) {
				if (res.confirm) {
					if (that.data.shotupfee > 0) {
						if (that.data.shotrestups > 0) {
							getApp().util.request({
								url: 'entry/wxapp/shotupsuccess',
								data: {
									id: res_id,openid:openid,up:1
								},
								success: function (res) {
									if (res.data.code == 200) {
										that.data.shotmlist[e.currentTarget.dataset.index].upfee = 1
										that.setData({
											shotmlist: that.data.shotmlist
										})
										wx.showToast({
											icon: "none",
											title: '推荐成功',
										})
									} else {
										wx.showToast({
											icon: "none",
											title: '推荐失败',
										})
									}
								}
							})
						} else {
							getApp().util.request({
								url: 'entry/wxapp/shotuppay',
								data: {
									openid: openid,
								},
								success: function (res) {
									wx.requestPayment({
										'timeStamp': res.data.timeStamp,
										'nonceStr': res.data.nonceStr,
										'package': res.data.package,
										'signType': 'MD5',
										'paySign': res.data.paySign,
										'success': function (res) {
											getApp().util.request({
												url: 'entry/wxapp/shotupsuccess',
												data: {
													id: res_id
												},
												success: function (rest) {
													if (rest.data.code == 200) {
														that.data.shotmlist[e.currentTarget.dataset.index].upfee = 1
														that.setData({
															shotmlist: that.data.shotmlist
														})
														wx.showToast({
															icon: "none",
															title: '推荐成功',
														})
													} else {
														wx.showToast({
															icon: "none",
															title: '推荐失败',
														})
													}
												}
											})

										},
										'fail': function (res) {
											;
											wx.showToast({
												title: '支付失败',
												icon: "loading",
											})
										}
									})
								}
							})
						}
					}
					else {
						getApp().util.request({
							url: 'entry/wxapp/shotupsuccess',
							data: {
								id: res_id
							},
							success: function (res) {
								
								if (res.data.code == 200) {
									that.data.shotmlist[e.currentTarget.dataset.index].upfee = 1
									that.setData({
										shotmlist: that.data.shotmlist
									})
									wx.showToast({
										icon: "none",
										title: '推荐成功',
									})
								} else {
									wx.showToast({
										icon: "none",
										title: '推荐失败',
									})
								}
							}
						})
					}
				} else if (res.cancel) {
				}
			}
		})
	},
	shottopfee: function (e) {
		var that = this
		var res_id = e.currentTarget.dataset.id
		var openid = wx.getStorageSync('openid')
		wx.showModal({
			title: '提示',
			content: '是否确认置顶本条微拍？',
			success: function (res) {
				if (res.confirm) {
					if (that.data.shottopfee > 0) {
						if(that.data.shotresttops>0){
							getApp().util.request({
								url: 'entry/wxapp/shottopsuccess',
								data: {
									id: res_id,openid:openid,top:1
								},
								success: function (res) {
									if (res.data.code == 200) {
										wx.showToast({
											icon: "none",
											title: '置顶成功',
										})
									} else {
										wx.showToast({
											icon: "none",
											title: '置顶失败',
										})
									}
								}
							})
						} else {
							getApp().util.request({
								url: 'entry/wxapp/shottoppay',
								data: {
									openid: openid,
								},
								success: function (res) {
									wx.requestPayment({
										'timeStamp': res.data.timeStamp,
										'nonceStr': res.data.nonceStr,
										'package': res.data.package,
										'signType': 'MD5',
										'paySign': res.data.paySign,
										'success': function (res) {
											getApp().util.request({
												url: 'entry/wxapp/shottopsuccess',
												data: {
													id: res_id
												},
												success: function (rest) {
													if (rest.data.code == 200) {
														wx.showToast({
															icon: "none",
															title: '置顶成功',
														})
													} else {
														wx.showToast({
															icon: "none",
															title: '置顶失败',
														})
													}
												}
											})

										},
										'fail': function (res) {
											;
											wx.showToast({
												title: '支付失败',
												icon: "loading",
											})
										}
									})
								}
							})
						}
					}
					else {
						getApp().util.request({
							url: 'entry/wxapp/shottopsuccess',
							data: {
								id: res_id
							},
							success: function (res) {
								
								if (res.data.code == 200) {
									wx.showToast({
										icon: "none",
										title: '置顶成功',
									})
								} else {
									wx.showToast({
										icon: "none",
										title: '置顶失败',
									})
								}
							}
						})
					}
				} else if (res.cancel) {
					
				}
			}
		})
	},
	marketupfee: function (e) {
		var that = this
		var res_id = e.currentTarget.dataset.id
		var openid = wx.getStorageSync('openid')
		wx.showModal({
			title: '提示',
			content: '是否确认推荐本条地摊？',
			success: function (res) {
				if (res.confirm) {
					if (that.data.marketupfee > 0) {
						if(that.data.marketrestups>0){
							getApp().util.request({
								url: 'entry/wxapp/marketupsuccess',
								data: {
									id: res_id,openid:openid,up:1
								},
								success: function (res) {
									if (res.data.code == 200) {
										that.data.marketmlist[e.currentTarget.dataset.index].upfee = 1
										that.setData({
											marketmlist: that.data.marketmlist
										})
										wx.showToast({
											icon: "none",
											title: '推荐成功',
										})
									} else {
										wx.showToast({
											icon: "none",
											title: '推荐失败',
										})
									}
								}
							})
						} else {
							getApp().util.request({
								url: 'entry/wxapp/marketuppay',
								data: {
									openid: openid,
								},
								success: function (res) {
									wx.requestPayment({
										'timeStamp': res.data.timeStamp,
										'nonceStr': res.data.nonceStr,
										'package': res.data.package,
										'signType': 'MD5',
										'paySign': res.data.paySign,
										'success': function (res) {
											getApp().util.request({
												url: 'entry/wxapp/marketupsuccess',
												data: {
													id: res_id
												},
												success: function (rest) {
													if (rest.data.code == 200) {
														that.data.marketmlist[e.currentTarget.dataset.index].upfee = 1
														that.setData({
															marketmlist: that.data.marketmlist
														})
														wx.showToast({
															icon: "none",
															title: '推荐成功',
														})
													} else {
														wx.showToast({
															icon: "none",
															title: '推荐失败',
														})
													}
												}
											})

										},
										'fail': function (res) {
											;
											wx.showToast({
												title: '支付失败',
												icon: "loading",
											})
										}
									})
								}
							})
						}
					}
					else {
						getApp().util.request({
							url: 'entry/wxapp/marketupsuccess',
							data: {
								id: res_id
							},
							success: function (res) {
								if (res.data.code == 200) {
									that.data.marketmlist[e.currentTarget.dataset.index].upfee = 1
									that.setData({
										marketmlist: that.data.marketmlist
									})
									wx.showToast({
										icon: "none",
										title: '推荐成功',
									})
								} else {
									wx.showToast({
										icon: "none",
										title: '推荐失败',
									})
								}
							}
						})
					}
				} else if (res.cancel) {
				}
			}
		})
	},
	markettopfee: function (e) {
		var that = this
		var res_id = e.currentTarget.dataset.id
		var openid = wx.getStorageSync('openid')
		wx.showModal({
			title: '提示',
			content: '是否确认置顶本条地摊？',
			success: function (res) {
				if (res.confirm) {
					if (that.data.markettopfee > 0) {
						if(that.data.marketresttops>0){
							getApp().util.request({
								url: 'entry/wxapp/markettopsuccess',
								data: {
									id: res_id,openid:openid,top:1
								},
								success: function (res) {

									if (res.data.code == 200) {
										wx.showToast({
											icon: "none",
											title: '置顶成功',
										})
									} else {
										wx.showToast({
											icon: "none",
											title: '置顶失败',
										})
									}
								}
							})
						} else {
							getApp().util.request({
								url: 'entry/wxapp/markettoppay',
								data: {
									openid: openid,
								},
								success: function (res) {
									wx.requestPayment({
										'timeStamp': res.data.timeStamp,
										'nonceStr': res.data.nonceStr,
										'package': res.data.package,
										'signType': 'MD5',
										'paySign': res.data.paySign,
										'success': function (res) {
											getApp().util.request({
												url: 'entry/wxapp/markettopsuccess',
												data: {
													id: res_id
												},
												success: function (rest) {
													if (rest.data.code == 200) {
														wx.showToast({
															icon: "none",
															title: '置顶成功',
														})
													} else {
														wx.showToast({
															icon: "none",
															title: '置顶失败',
														})
													}
												}
											})

										},
										'fail': function (res) {
											;
											wx.showToast({
												title: '支付失败',
												icon: "loading",
											})
										}
									})
								}
							})
						}
					}
					else {
						getApp().util.request({
							url: 'entry/wxapp/markettopsuccess',
							data: {
								id: res_id
							},
							success: function (res) {
								
								if (res.data.code == 200) {
									wx.showToast({
										icon: "none",
										title: '置顶成功',
									})
								} else {
									wx.showToast({
										icon: "none",
										title: '置顶失败',
									})
								}
							}
						})
					}
				} else if (res.cancel) {
					
				}
			}
		})
	},
	storeupfee: function (e) {
		var that = this
		var res_id = e.currentTarget.dataset.id
		var openid = wx.getStorageSync('openid')
		wx.showModal({
			title: '提示',
			content: '是否确认推荐本条商品？',
			success: function (res) {
				if (res.confirm) {
					if (that.data.storeupfee > 0) {
						if(that.data.storesrestups>0){
							getApp().util.request({
								url: 'entry/wxapp/storeupsuccess',
								data: {
									id: res_id,openid:openid,up:1
								},
								success: function (res) {
									if (res.data.code == 200) {
										that.data.storemlist[e.currentTarget.dataset.index].upfee = 1
										that.setData({
											storemlist: that.data.storemlist
										})
										wx.showToast({
											icon: "none",
											title: '推荐成功',
										})
									} else {
										wx.showToast({
											icon: "none",
											title: '推荐失败',
										})
									}
								}
							})
						} else {
							getApp().util.request({
								url: 'entry/wxapp/storeuppay',
								data: {
									openid: openid,
								},
								success: function (res) {
									wx.requestPayment({
										'timeStamp': res.data.timeStamp,
										'nonceStr': res.data.nonceStr,
										'package': res.data.package,
										'signType': 'MD5',
										'paySign': res.data.paySign,
										'success': function (res) {
											getApp().util.request({
												url: 'entry/wxapp/storeupsuccess',
												data: {
													id: res_id
												},
												success: function (rest) {
													if (rest.data.code == 200) {
														that.data.storemlist[e.currentTarget.dataset.index].upfee = 1
														that.setData({
															storemlist: that.data.storemlist
														})
														wx.showToast({
															icon: "none",
															title: '推荐成功',
														})
													} else {
														wx.showToast({
															icon: "none",
															title: '推荐失败',
														})
													}
												}
											})

										},
										'fail': function (res) {
											;
											wx.showToast({
												title: '支付失败',
												icon: "loading",
											})
										}
									})
								}
							})
						}
					}
					else {
						getApp().util.request({
							url: 'entry/wxapp/storeupsuccess',
							data: {
								id: res_id
							},
							success: function (res) {
								
								if (res.data.code == 200) {
									that.data.storemlist[e.currentTarget.dataset.index].upfee = 1
									that.setData({
										storemlist: that.data.storemlist
									})
									wx.showToast({
										icon: "none",
										title: '推荐成功',
									})
								} else {
									wx.showToast({
										icon: "none",
										title: '推荐失败',
									})
								}
							}
						})
					}
				} else if (res.cancel) {
					
				}
			}
		})
	},
	storetopfee: function (e) {
		var that = this
		var res_id = e.currentTarget.dataset.id
		var openid = wx.getStorageSync('openid')
		wx.showModal({
			title: '提示',
			content: '是否确认置顶本条商城商品？',
			success: function (res) {
				if (res.confirm) {
					if (that.data.storetopfee > 0) {
						if(that.data.storesresttops>0){
							getApp().util.request({
								url: 'entry/wxapp/storetopsuccess',
								data: {
									id: res_id,openid:openid,top:1
								},
								success: function (res) {
									if (res.data.code == 200) {
										wx.showToast({
											icon: "none",
											title: '置顶成功',
										})
									} else {
										wx.showToast({
											icon: "none",
											title: '置顶失败',
										})
									}
								}
							})
						}else{
							getApp().util.request({
								url: 'entry/wxapp/storetoppay',
								data: {
									openid: openid,
								},
								success: function (res) {
									wx.requestPayment({
										'timeStamp': res.data.timeStamp,
										'nonceStr': res.data.nonceStr,
										'package': res.data.package,
										'signType': 'MD5',
										'paySign': res.data.paySign,
										'success': function (res) {
											getApp().util.request({
												url: 'entry/wxapp/storetopsuccess',
												data: {
													id: res_id
												},
												success: function (rest) {
													if (rest.data.code == 200) {
														wx.showToast({
															icon: "none",
															title: '置顶成功',
														})
													} else {
														wx.showToast({
															icon: "none",
															title: '置顶失败',
														})
													}
												}
											})

										},
										'fail': function (res) {
											;
											wx.showToast({
												title: '支付失败',
												icon: "loading",
											})
										}
									})
								}
							})
						}
					}
					else {
						getApp().util.request({
							url: 'entry/wxapp/storetopsuccess',
							data: {
								id: res_id
							},
							success: function (res) {
								if (res.data.code == 200) {
									wx.showToast({
										icon: "none",
										title: '置顶成功',
									})
								} else {
									wx.showToast({
										icon: "none",
										title: '置顶失败',
									})
								}
							}
						})
					}
				} else if (res.cancel) {
					
				}
			}
		})
	},
	priupfee: function (e) {
		var that = this
		var res_id = e.currentTarget.dataset.id
		var openid = wx.getStorageSync('openid')
		wx.showModal({
			title: '提示',
			content: '是否确认推荐本条定制？',
			success: function (res) {
				if (res.confirm) {
					if (that.data.priupfee > 0) {
						if(that.data.foryourestups>0){
							getApp().util.request({
								url: 'entry/wxapp/priupsuccess',
								data: {
									id: res_id,openid:openid,up:1
								},
								success: function (res) {
									if (res.data.code == 200) {
										that.data.primlist[e.currentTarget.dataset.index].upfee = 1
										that.setData({
											primlist: that.data.primlist
										})
										wx.showToast({
											icon: "none",
											title: '推荐成功',
										})
									} else {
										wx.showToast({
											icon: "none",
											title: '推荐失败',
										})
									}
								}
							})
						}else{
							getApp().util.request({
								url: 'entry/wxapp/priuppay',
								data: {
									openid: openid,
								},
								success: function (res) {
									wx.requestPayment({
										'timeStamp': res.data.timeStamp,
										'nonceStr': res.data.nonceStr,
										'package': res.data.package,
										'signType': 'MD5',
										'paySign': res.data.paySign,
										'success': function (res) {
											getApp().util.request({
												url: 'entry/wxapp/priupsuccess',
												data: {
													id: res_id
												},
												success: function (rest) {
													if (rest.data.code == 200) {
														that.data.primlist[e.currentTarget.dataset.index].upfee = 1
														that.setData({
															primlist: that.data.primlist
														})
														wx.showToast({
															icon: "none",
															title: '推荐成功',
														})
													} else {
														wx.showToast({
															icon: "none",
															title: '推荐失败',
														})
													}
												}
											})
										},
										'fail': function (res) {
											;
											wx.showToast({
												title: '支付失败',
												icon: "loading",
											})
										},
										'complete': function (res) {
											;
											wx.showToast({
												title: '取消支付',
												icon: "loading",
											})
										}
									})
								}
							})
						}
					}
					else {
						getApp().util.request({
							url: 'entry/wxapp/priupsuccess',
							data: {
								id: res_id
							},
							success: function (res) {
								
								if (res.data.code == 200) {
									that.data.primlist[e.currentTarget.dataset.index].upfee = 1
									that.setData({
										primlist: that.data.primlist
									})
									wx.showToast({
										icon: "none",
										title: '推荐成功',
									})
								} else {
									wx.showToast({
										icon: "none",
										title: '推荐失败',
									})
								}
							}
						})
					}
				} else if (res.cancel) {
					
				}
			}
		})
	},
	pritopfee: function (e) {
		var that = this
		var res_id = e.currentTarget.dataset.id
		var openid = wx.getStorageSync('openid')
		wx.showModal({
			title: '提示',
			content: '是否确认置顶本条定制？',
			success: function (res) {
				if (res.confirm) {
					if (that.data.pritopfee > 0) {
						if(that.data.foryouresttops>0){
							getApp().util.request({
								url: 'entry/wxapp/pritopsuccess',
								data: {
									id: res_id,openid:openid,top:1
								},
								success: function (res) {
									if (res.data.code == 200) {
										wx.showToast({
											icon: "none",
											title: '置顶成功',
										})
									} else {
										wx.showToast({
											icon: "none",
											title: '置顶失败',
										})
									}
								}
							})
						} else {
							getApp().util.request({
								url: 'entry/wxapp/pritoppay',
								data: {
									openid: openid,
								},
								success: function (res) {

									wx.requestPayment({
										'timeStamp': res.data.timeStamp,
										'nonceStr': res.data.nonceStr,
										'package': res.data.package,
										'signType': 'MD5',
										'paySign': res.data.paySign,
										'success': function (res) {
											getApp().util.request({
												url: 'entry/wxapp/pritopsuccess',
												data: {
													id: res_id
												},
												success: function (rest) {
													if (rest.data.code == 200) {
														wx.showToast({
															icon: "none",
															title: '置顶成功',
														})
													} else {
														wx.showToast({
															icon: "none",
															title: '置顶失败',
														})
													}
												}
											})

										},
										'fail': function (res) {
											;
											wx.showToast({
												title: '支付失败',
												icon: "loading",
											})
										}
									})
								}
							})
						}
					}
					else {
						getApp().util.request({
							url: 'entry/wxapp/pritopsuccess',
							data: {
								id: res_id
							},
							success: function (res) {
								if (res.data.code == 200) {
									wx.showToast({
										icon: "none",
										title: '置顶成功',
									})
								} else {
									wx.showToast({
										icon: "none",
										title: '置顶失败',
									})
								}
							}
						})
					}
				} else if (res.cancel) {
					
				}
			}
		})
	},
})